;$(function() {
	$.subscribe('click_zoomin', __zoom,false)
	 .subscribe('click_zoomout',__zoom,false)
	 .subscribe('click_img_left',__rotate,false)
	 .subscribe('click_img_right',__rotate,false)
	 .subscribe('click_feed_delete',__delete,false)
	 .subscribe('feed_create',__create,false);
	var $stream = $("div.feed_body");
	function __zoom(t,e,action) {
		if(action == 'click_zoomin') {
			$(t).closest('.zoomin').hide().next().show();
		} else {
			$(t).closest('.pic').hide().prev().show();
		}
	}
	function __rotate(t,e,action) {
		if(action == 'click_img_left') {
			$(t).closest('.pic').find('img').rotateLeft();
		} else {
			$(t).closest('.pic').find('img').rotateRight();
		}
	}
	function __delete(t,e,action) {
		var $t = $(t);
		var offset = $t.offset();
		var height = $t.outerHeight();
		$(t).confirm('<div style="width:210px">确定要删除此微博么?一旦删除不可恢复</div>',{
			left : offset.left - 171,
			top : offset.top + height + 5,
			onAccept:function() {
				$t.closest('.item').fadeOut('slow',function() {
					$(this).remove();
				});
			},
			onCancel:function() {
				$.publish('ui_hide');
			}
		});
	}
	function __create(data) {
		var html = data.html;
		if(typeof html == 'string') {
			$stream.prepend($(html).fadeIn());
		}
	}
});